﻿using System;
using System.Collections.Generic;
using Castle.ActiveRecord;

namespace Hadlow.Jobvertizer.Models
{
    [ActiveRecord]
    public class Location : Entity
    {
        string name;

        [Property]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        Location parent;

        [BelongsTo("ParentId")]
        public Location Parent
        {
            get { return parent; }
            set { parent = value; }
        }

        IList<Location> children = new List<Location>();

        [HasMany(Cascade = ManyRelationCascadeEnum.AllDeleteOrphan)]
        public IList<Location> Children
        {
            get { return children; }
            set { children = value; }
        }

        public override string ToString()
        {
            return name;
        }
    }
}
